package Controller;

import Enums.ABMAction;
import View.ABMBaseView;

public abstract class ABMBaseController 
{
	protected ABMAction action;
	private ABMBaseView view;

	public ABMAction getAction()
	{
		return this.action;
	}
	
	public ABMBaseView getView()
	{
		return this.view;
	}
	
	public ABMBaseController(ABMAction action, ABMBaseView view)
	{
		this.action = action;
		this.view = view;
	}
	
	public void init()
	{
		view.showPanelDeEdicion(action == ABMAction.Alta);
		view.showGrillaDatos(true);
		
		view.showBotonCancelar(true);
		view.showBotonGuardar(action == ABMAction.Modificacion || action == ABMAction.Alta);
		view.showBotonEliminar(action == ABMAction.Baja);
	}
	
	public void objetoSeleccionado(int index)
	{
		view.showPanelDeEdicion(true);
	}
	
	public abstract void Guardar();
	public abstract void Eliminar();
	
	public void Cancelar()
	{
		if (action == ABMAction.Alta)
		{
			this.view.clean();
		}
		else
		{
			this.view.showPanelDeEdicion(false);
		}
	}
}
